package com.efruit.struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.efruit.externalInterfaces.IProductInfoMag;
import com.efruit.productInfoMag.IProductInfo;

public class BrowseAction extends Action {
	private IProductInfoMag mag;
	
	public IProductInfoMag getMag() {
		return mag;
	}

	public void setMag(IProductInfoMag mag) {
		this.mag = mag;
	}

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		List p = mag.getAllProductInfo();
		System.out.println(((IProductInfo)p.get(0)).getProductId());
		System.out.println(((IProductInfo)p.get(1)).getProductId());
		if (p != null) {
			request.setAttribute("product", p);
			return mapping.findForward("select");
		}
		return mapping.findForward("error");
	}
}
